package graphics;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.io.Serializable;

/**
 * Shape is the super class of any shapes in this application
 * 
 * @author Jie Zhao(288654)
 * 
 */
public abstract class Shape implements Serializable {
	protected Color filledColor = null;
	protected boolean isFilled = false;
	protected Color lineColor = null;
	protected BasicStroke stroke = null;

	public Shape() {
		filledColor = Color.BLACK;
		lineColor = Color.BLACK;
		stroke = new BasicStroke(1);
	}
/**
 * convert a shape to a string which represents the shape.
 */
	public abstract String toString();

	/**
	 * Construct a shape from the given string
	 * @param str
	 */
	public abstract void fromString(String str);

	/**
	 * draw the shape
	 * 
	 * @param g
	 */
	public void draw(Graphics g) {
		Graphics2D g2d = (Graphics2D) g;
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON);
	}

	/**
	 * 
	 * @return filled color of this shape
	 */
	public Color getFilledColor() {
		return filledColor;
	}

	/**
	 * set filled color of this shape
	 * 
	 * @param fillColor
	 */
	public void setFilledColor(Color fillColor) {
		this.filledColor = fillColor;
	}

	/**
	 * 
	 * @return true if the shape is filled;false if not
	 */
	public boolean isFilled() {
		return isFilled;
	}

	/**
	 * set if the shape is filled or not
	 * 
	 * @param isFilled
	 */
	public void setFilled(boolean isFilled) {
		this.isFilled = isFilled;
	}

	/**
	 * @return the line color of this shape
	 */
	public Color getLineColor() {
		return lineColor;
	}

	/**
	 * set line color
	 * 
	 * @param lineColor
	 */
	public void setLineColor(Color lineColor) {
		this.lineColor = lineColor;
	}

	/**
	 * 
	 * @return the stroke of this shape
	 */
	public BasicStroke getStroke() {
		return stroke;
	}

	/**
	 * set stroke for this shape
	 * 
	 * @param stroke
	 */
	public void setStroke(BasicStroke stroke) {
		this.stroke = stroke;
	}

}
